import 'package:flutter/material.dart';
import 'package:fzcgx_app/common/adapter_utils.dart';
import 'package:fzcgx_app/common/assets_utils.dart';
import 'package:fzcgx_app/provider/provider_widget.dart';
import 'package:fzcgx_app/ui/base/base_view_model.dart';
import 'package:fzcgx_app/ui/my/worker/view_model/worker_education_background_view_model.dart';
import 'package:fzcgx_app/ui/widget/custom_appbar_widget.dart';

class WorkerObjectCompanyPage extends StatefulWidget {
  WorkerObjectCompanyPage({Key key}) : super(key: key);

  @override
  _WorkerObjectCompanyPageState createState() => _WorkerObjectCompanyPageState();
}

class _WorkerObjectCompanyPageState extends State<WorkerObjectCompanyPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: CustomAppbar(
        title: '求职意向',
        actions: <Widget>[
          InkWell(
              onTap: () {
                showDialog<Null>(
                  context: context,
                  builder: (BuildContext context) {
                    return Dialog(
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(15)),
                        child: Container(
                          height: AdapterUtils.screenHeight() / 2 - 35,
                          padding: EdgeInsets.all(15),
                          child: Column(
                            children: <Widget>[
                              Text(
                                '求职意向',
                                style: TextStyle(
                                  fontSize: AdapterUtils.getSp(16),
                                  color: Color(0xff3B4859),
                                  fontWeight: FontWeight.bold,
                                ),
                              ),
                              SizedBox(
                                height: AdapterUtils.getHeight(37),
                              ),
                              Container(
                                decoration: BoxDecoration(
                                    border: Border(
                                        bottom: BorderSide(
                                            color: Color(0xffE8E9ED),
                                            width: 1))),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: <Widget>[
                                    RichText(
                                      text: TextSpan(children: <InlineSpan>[
                                        TextSpan(
                                            text: '求职意向名称',
                                            style: TextStyle(
                                              fontSize: AdapterUtils.getSp(14),
                                              color: Color(0xff606B79),
                                              fontWeight: FontWeight.w500,
                                            )),
                                        TextSpan(
                                            text: '',
                                            style: TextStyle(
                                              fontSize: AdapterUtils.getSp(14),
                                              color: Color(0xffFF1515),
                                              fontWeight: FontWeight.w500,
                                            )),
                                      ]),
                                    ),
                                    TextField(
                                      //  controller: viewModel.nameController,

                                      style: TextStyle(
                                        fontSize: AdapterUtils.getSp(18),
                                        color: Color(0xff3B4859),
                                        fontWeight: FontWeight.w500,
                                      ),
                                      decoration: InputDecoration(
                                          contentPadding: EdgeInsets.only(
                                              top: AdapterUtils.getHeight(10),
                                              bottom:
                                                  AdapterUtils.getHeight(20)),
                                          hintText: '请输入',
                                          border: InputBorder.none,
                                          hintStyle: TextStyle(
                                            fontSize: AdapterUtils.getSp(18),
                                            color: Color(0xffD7D8DB),
                                            fontWeight: FontWeight.w500,
                                          )),
                                    )
                                  ],
                                ),
                              ),
                              SizedBox(
                                height: AdapterUtils.getHeight(35),
                              ),
                              Container(
                                  width: AdapterUtils.screenWidth(),
                                  height: AdapterUtils.getHeight(50),
                                  child: FlatButton(
                                      onPressed: () {
                                        //  viewModel.addDepartApi(context);
                                      },
                                      disabledColor:
                                          Color(0xff15A1FF).withAlpha(80),
                                      color: Color(0xff15A1FF),
                                      shape: RoundedRectangleBorder(
                                        borderRadius: BorderRadius.all(
                                            Radius.circular(4)),
                                      ),
                                      child: Text(
                                        '确认新增',
                                        style: TextStyle(
                                          fontSize: AdapterUtils.getSp(16),
                                          color: Colors.white,
                                          fontWeight: FontWeight.w500,
                                        ),
                                      ))),
                            ],
                          ),
                        ));
                  },
                ).then((val) {
                  print(val);
                });
              },
              child: Container(
                alignment: Alignment.centerRight,
                margin: EdgeInsets.only(right: AdapterUtils.getWidth(15)),
                child: Text(
                  '新增',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(16),
                    color: Color(0xff15A1FF),
                    fontWeight: FontWeight.w500,
                  ),
                ),
              ))
        ],
      ),
      body: SafeArea(
          child: ProviderWidget<WorkerEducationBackgroundViewModel>(
        model: WorkerEducationBackgroundViewModel(),
        onReady: (viewModel) {
          viewModel.requestApi();
        },
        builder: (context, viewModel, child) {
          return SingleChildScrollView(
            child: viewModel.state == ViewState.Success
                ? _buildSuccessWidget(viewModel)
                : Container(),
          );
        },
      )),
    );
  }

  Widget _buildSuccessWidget(WorkerEducationBackgroundViewModel viewModel) {
    return Container(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          SizedBox(
            height: AdapterUtils.getHeight(4),
          ),
          Container(
            height: AdapterUtils.getHeight(38),
            color: Color(0xffEAF7FE),
            child: Center(
              child: Text(
                '注册填写/上传的信息越全面，客户信任度越高',
                style: TextStyle(
                  fontSize: AdapterUtils.getSp(13),
                  color: Color(0xff15A1FF),
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(28),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            child: Text(
              '求职意向1',
              style: TextStyle(
                fontSize: AdapterUtils.getSp(18),
                color: Color(0xff141F33),
                fontWeight: FontWeight.bold,
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '地点',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择地点':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '职能',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择职能':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
            decoration: BoxDecoration(
                border: Border(
                    bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(
                  '职位',
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(14),
                    color: Color(0xff606B79),
                    fontWeight: FontWeight.w500,
                  ),
                ),
                TextField(
                  controller: viewModel.nameController,
                  style: TextStyle(
                    fontSize: AdapterUtils.getSp(18),
                    color: Color(0xff3B4859),
                    fontWeight: FontWeight.w500,
                  ),
                  decoration: InputDecoration(
                      contentPadding: EdgeInsets.only(
                          top: AdapterUtils.getHeight(10),
                          bottom: AdapterUtils.getHeight(20)),
                      hintText: '请输入职位',
                      border: InputBorder.none,
                      hintStyle: TextStyle(
                        fontSize: AdapterUtils.getSp(18),
                        color: Color(0xffD7D8DB),
                        fontWeight: FontWeight.w500,
                      )),
                )
              ],
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '期望薪资',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择期望薪资':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '工作类型',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择工作类型':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '行业',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择行业':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '到岗时间',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择到岗时间':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
          SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
          InkWell(
            onTap: (){
              viewModel.onShowBottomBirthDateSheet(context);
            },
            child: Container(
              margin:
                  EdgeInsets.symmetric(horizontal: AdapterUtils.getWidth(15)),
              padding: EdgeInsets.only(bottom: AdapterUtils.getHeight(10)),
              decoration: BoxDecoration(
                  border: Border(
                      bottom: BorderSide(color: Color(0xffE8E9ED), width: 1))),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(
                    '个人标签',
                    style: TextStyle(
                      fontSize: AdapterUtils.getSp(14),
                      color: Color(0xff606B79),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                 Container(
                   height: AdapterUtils.getHeight(54),
                   child:  Row(
                     mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: <Widget>[
                      Text(viewModel.model.chushengnianyue.isEmpty? '请选择个人标签':viewModel.model.chushengnianyue,
                          style: TextStyle(
                            fontSize: AdapterUtils.getSp(18),
                            color: viewModel.model.chushengnianyue.isEmpty? Color(0xffD7D8DB):Color(0xff3B4859),
                            fontWeight: FontWeight.w500,
                          )),
                          Image.asset(AssetsUtils.getAssetsImagesPath('arrow_right.png'),width: 
                          AdapterUtils.getWidth(30),height: AdapterUtils.getHeight(30),)
                    ],
                  ),
                 )
                ],
              ),
            ),
          ),
           SizedBox(
            height: AdapterUtils.getHeight(24),
          ),
           Container(
                width: AdapterUtils.screenWidth(),
                height: AdapterUtils.getHeight(50),
                 margin: EdgeInsets.all(15),
                child: FlatButton(
                    onPressed:  () {
                    //  viewModel.onPostApi(context);
                    },
                    disabledColor: Color(0xff15A1FF).withAlpha(80),
                    color: Color(0xff15A1FF),
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                    child: Text(
                      '保存',
                      style: TextStyle(
                        fontSize: AdapterUtils.getSp(16),
                        color: Colors.white,
                        fontWeight: FontWeight.w500,
                      ),
                    ))),
            SizedBox(
              height: AdapterUtils.getHeight(16),
            ),
        ],
      ),
    );
  }
}
